

package com.hazelcast.internal.dynamicconfig;

import com.hazelcast.config.UserCodeNamespaceAwareConfig;
import com.hazelcast.internal.cluster.ClusterService;
import com.hazelcast.nio.serialization.IdentifiedDataSerializable;
import com.hazelcast.spi.impl.operationservice.Operation;

/**
 * Supplier that creates {@link AddDynamicConfigOperation}s for a given config.
 */
public class AddDynamicConfigOperationSupplier extends DynamicConfigOperationSupplier {
    public AddDynamicConfigOperationSupplier(ClusterService clusterService, IdentifiedDataSerializable config) {
        super(clusterService, config);
    }

    @Override
    public Operation get() {
        return new AddDynamicConfigOperation(config, clusterService.getMemberListVersion(), config instanceof UserCodeNamespaceAwareConfig awareConfig ? awareConfig.getUserCodeNamespace() : null);
    }
}
